<!DOCTYPE html>
<html lang="en">

<head>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>监控中心 - 报警记录</title>

    <!-- Bootstrap Core CSS -->
    <link href="${request.getContextPath()}/public/vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">

    <!-- MetisMenu CSS -->
    <link href="${request.getContextPath()}/public/vendor/metisMenu/metisMenu.min.css" rel="stylesheet">

    <!-- Custom CSS -->
    <link href="${request.getContextPath()}/public/dist/css/sb-admin-2.css" rel="stylesheet">

    <!-- Custom Fonts -->
    <link href="${request.getContextPath()}/public/vendor/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">

    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
        <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
        <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->

</head>

<body>

    <div id="wrapper">

        <!--嵌入头部跟菜单-->
        <#include "/admin/inc/menu.html"/>

        <!-- Page Content -->
        <div id="page-wrapper">
            <div class="container-fluid">

                <div class="row">
                    <div class="col-lg-10">
                        <h4 class="page-header">报警记录 —— 仓单编号：${receipt.no}</h4>
                    </div>
                    <!-- /.col-lg-12 -->
                    <div class="col-lg-2">
                        <a href="${request.getContextPath()}/admin/receipt/listByWh.do?whId=${receipt.warehouse.id}" class="btn btn-primary page-header"> <li class="fa fa-reply"></li>  返回仓单列表</a>
                    </div>
                </div>
        <!-- /.row -->

        <#if groupAlamMap??>
            <#list groupAlamMap?keys as date>

                <div class="row">
                    <!--按日期排列报警记录列表，无报警记录的日期不显示，列表中包含待处理、已处理的所有报警记录-->
                    <h3 class="page-header">${date}</h3>

                    <div class="row">
                    <#list groupAlamMap[date] as alam>
                            <!--报警记录列表-->
                            <div class="col-lg-3">
                                <div class="panel panel-default">
                                    <div class="panel-body">
                                        <a href="#" onclick="showAlam(this);"
                                           data-alaminfo='{"id":${alam.id?c},"captureImageUrl":"${alam.captureImageUrl}","tagNo":"${(alam.tag.no)!"无RFID编号"}","alamTime":"${alam.alamTime}","status":"${alam.status}","processTime":"${alam.processTime!""}","processDesc":"${alam.processDesc!""}"}'>
                                            <img class="img-responsive" src="${alam.captureImageUrl!''}">
                                        </a>
                                    </div>
                                    <div class="panel-footer">
                                        <div class="row">
                                            <table class="table table-bordered table-striped">
                                                <tr>
                                                    <td>报警时间：</td>
                                                    <td>${alam.alamTime}</td>
                                                </tr>
                                                <tr>
                                                    <td>处理状态：</td>
                                                    <#if alam.status==0>
                                                        <td style="color: red"> 待处理</td>
                                                    <#else>
                                                        <td style="color: green"> 已处理</td>
                                                    </#if>
                                                </tr>
                                            </table>
                                        </div>
                                    </div>
                                </div>
                            </div>
                    </#list>
                    </div>

                </div>

            </#list>

        </#if>


            <!-- /.container-fluid -->
        </div>
        <!-- /#page-wrapper -->

    </div>
    <!-- /#wrapper -->


    </div>

    <!--报警详情模板-->
    <div class="modal fade" id="alamInfo" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                    <h4 class="modal-title" id="myModalLabel">报警详情</h4>
                </div>
                <div class="modal-body">
                    <img id="alam_image" class="img-responsive" src="">
                    <div class="row show-grid">
                        <input type="hidden" id="alam_id" value="" />
                        <div  class="col-md-6">报警时间：<span id="alam_time"></span> </div>
                        <div  class="col-md-6">标签编号：<span id="alam_tag"></span> </div>
                        <div  class="col-md-6">处理状态：<span id="alam_status"></span></div>
                        <div  class="col-md-6">处理时间：<span id="alam_ds_time"></span></div>
                        <div  class="col-md-12">处理意见：<textarea id="alam_ds_desc" class="form-control" rows="3" placeholder="请输入处理意见"></textarea> </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    <button type="button" class="btn btn-primary" onclick="processAlam();">提交</button>
                </div>
            </div>
            <!-- /.modal-content -->
        </div>
        <!-- /.modal-dialog -->
    </div>


    <!-- jQuery -->
    <script src="${request.getContextPath()}/public/vendor/jquery/jquery.min.js"></script>

    <!-- Bootstrap Core JavaScript -->
    <script src="${request.getContextPath()}/public/vendor/bootstrap/js/bootstrap.min.js"></script>

    <!-- Metis Menu Plugin JavaScript -->
    <script src="${request.getContextPath()}/public/vendor/metisMenu/metisMenu.min.js"></script>

    <!-- Custom Theme JavaScript -->
    <script src="${request.getContextPath()}/public/dist/js/sb-admin-2.js"></script>


    <script>

        //显示报警信息详情
        function showAlam(dom){

            var alam = $(dom).data("alaminfo");

            console.log(alam.id);
            console.log(alam.alamTime);
            console.log(alam.captureImageUrl);
            console.log(alam.status);
            console.log(alam.processTime);
            console.log(alam.processDesc);

            //显示报警数据
            $("#alam_id").val(alam.id);
            $("#alam_image").attr('src', alam.captureImageUrl+'?' + Math.floor(Math.random()*100) );
            $("#alam_time").html(alam.alamTime);
            $("#alam_tag").html(alam.tagNo);
            $("#alam_ds_time").html(alam.processTime);
            $("#alam_ds_desc").val(alam.processDesc);

            var status_str = "待处理";
            if(alam.status==1){

                status_str="已处理";
            }

            $("#alam_status").html(status_str);

            //显示model
            $("#alamInfo").modal();

        }

        //处理报警
        function processAlam(){

            //获取编号
            var id=$("#alam_id").val();

            //获取处理意见
            var desc = $("#alam_ds_desc").val();

            console.log(id);
            console.log(desc);

            if(desc=="") alert("请输入处理意见");

            //提交
            var url ="${request.getContextPath()}/admin/alam/process.do";

            $.post(url,{id:id,desc:desc},function(data){

                alert(data.msg);

                //刷新页面
                location.reload();

            },"json");

        }

    </script>


</body>

</html>
